package main

import (
	"github.com/Shopify/sarama"
	"log"
	"time"
)

func main() {
	config := sarama.NewConfig()
	config.Producer.RequiredAcks = sarama.WaitForAll
	config.Producer.Partitioner = sarama.NewRandomPartitioner
	config.Producer.Return.Successes = true

	syncProducer, err := sarama.NewSyncProducer([]string{"ip:9092"}, config)
	if err != nil {
		panic(err)
	}

	tick := time.Tick(time.Second)

	for {
		partition, offset, err := syncProducer.SendMessage(&sarama.ProducerMessage{
			Topic: "hello",
			Value: sarama.StringEncoder("hello_value"),
		})
		if err != nil {
			panic(err)
		}

		log.Println("partition", partition, "offset", offset)
		//log.Println("Input")

		<-tick
	}

}
